package com.lhd.controller;

import com.alibaba.fastjson.JSONObject;
import com.lhd.service.Gd3Service;
import com.lhd.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/gd3")
public class Gd3Controller {
    @Autowired
    private Gd3Service gd3Service;

    @RequestMapping("/t1")
    public List<JSONObject> getShopMetrics(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getShopMetrics(date);

        return  list;
    }

    @RequestMapping("/t2")
    public List<JSONObject> getGoodsMetrics(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getGoodsMetrics(date);

        return  list;
    }

    @RequestMapping("/t3")
    public List<JSONObject> getZhMetrics(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getZhMetrics(date);

        return  list;
    }

    @RequestMapping("/t4")
    public List<JSONObject> getTypeUv(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getTypeUv(date);

        return  list;
    }

    @RequestMapping("/t5")
    public List<JSONObject> getPageAnalysis(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getPageAnalysis(date);

        return  list;
    }

    @RequestMapping("/t6")
    public List<JSONObject> getPageSource(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getPageSource(date);

        return  list;
    }

    @RequestMapping("/t7")
    public List<JSONObject> getKeyWord(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getKeyWord(date);

        return  list;
    }

    @RequestMapping("/t8")
    public List<JSONObject> getGoodsUv(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> list = gd3Service.getGoodsUv(date);

        return  list;
    }
}
